import { Injectable } from '@angular/core';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
import { ComputerInfo, ComputerService } from './computer.service';

@Injectable({
	providedIn: 'root',
})
export class DetailsService implements Resolve<ComputerInfo> {
	constructor(private computerService: ComputerService) {}
	async resolve(route: ActivatedRouteSnapshot) {
		const id = Number(route.queryParamMap.get('id'));
		return this.computerService.get(id);
	}
}
